package com.woniu.vo;

import com.woniu.enums.ResponseStatusEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author: 16327
 * @date: 2021/1/15 14:16
 * @description:响应码及信息
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseVo<T> {
    private Integer status;

    private String msg;

    private T data;


    public static  <T> ResponseVo<T> successNoData() {
        return new ResponseVo(ResponseStatusEnum.SUCCESS.getCode(), ResponseStatusEnum.SUCCESS.getMsg(), null);
    }
    public static <T> ResponseVo<T> errorNoDataWithMsg( String msg) {
        return new ResponseVo(ResponseStatusEnum.ERROR.getCode(), msg, null);
    }
    public static <T> ResponseVo<T> errorDefaultMsg(ResponseStatusEnum responseStatusEnum) {
        return new ResponseVo(responseStatusEnum.getCode(), responseStatusEnum.getMsg(), null);
    }
    public static <T> ResponseVo<T> successNoMsgWithData(T t) {
        return new ResponseVo(ResponseStatusEnum.SUCCESS.getCode(), null, t);
    }
    public static <T> ResponseVo<T> successWithMsgNoData(String msg) {
        return new ResponseVo(ResponseStatusEnum.SUCCESS.getCode(), msg, null);
    }

}
